package com.liufeng.test.spring.JseTest;

import com.google.gson.Gson;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Main {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {


        // printOther();
        Gson gson = new Gson();
        // for (int i = 1;i<8;i++){
        //     printSimple2(i);
        // }
        // System.out.println("==========================================");
        for (int i = 1;i<8;i++){
            printSimple(i);
        }
        // System.out.println("==========================================");
        // for (int i = 1;i<8;i++){
        //     printGson(i);
        // }


        Constructor<SimpleTest> con = SimpleTest.class.getDeclaredConstructor();
        con.setAccessible(true);
        SimpleTest simpleTest = con.newInstance();
        SimpleTest simpleTest2 = con.newInstance();
        System.out.println(simpleTest.hashCode());
        System.out.println(simpleTest2.hashCode());

    }
    private  static  void  printOther(){
        long startTime = System.nanoTime();
        System.out.println("================================"+(System.nanoTime()-startTime));
    }
    private static void printGson(int index){
        long startTime = System.nanoTime();
        System.out.println(index+"===="+new Gson().hashCode()+"time is "+(System.nanoTime()-startTime));
    }
    private static void printSimple(int index){
        long startTime = System.nanoTime();
        System.out.println(index+"===="+ EnumTest.INSTANCE.getGson().hashCode()+"time is "+(System.nanoTime()-startTime));
    }
    private static void printSimple2(int index){
        long startTime = System.nanoTime();
        System.out.println(index+"===="+ SimpleTest.getGson().hashCode()+"time is "+(System.nanoTime()-startTime));
    }


}
